# -*- coding: UTF-8 -*-
import json
import sys
import requests

def isset(v):
    try:
        type (eval(v))
    except:
        return False
    else:
        return True

def getJson(string,ind=4):
  return (json.dumps(string,ensure_ascii=False,
                    sort_keys=True,indent=ind,separators=(',',':')))

def saveJson(path,thedict,ind=4):
    with open(path,"w",encoding="utf-8") as thefile:
        thefile.write(getJson(thedict))

def loadJson(path):
    thedict = {}
    with open(path,"r",encoding="utf-8") as thefile:
        thedict = json.loads(thefile.read())
    return thedict

def getURLData(url):
    #requests.get 自带 json.load
    page = requests.get(url)
    page = page.content
    #将bytes转换成字符串
    page = page.decode('utf-8')
    return  page